package com.cskaoyan.market.service.impl;

import com.cskaoyan.market.db.domain.MarketAdExample;
import com.cskaoyan.market.db.mapper.MarketAdMapper;
import com.cskaoyan.market.service.AdminAdDeleteService;
import com.cskaoyan.market.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

/**
 * @author Meltedicecream
 * @since 2023/06/20 11:44
 */
public class AdminAdDeleteServiceImpl implements AdminAdDeleteService {

    @Override
    public int delete(String id) {
        SqlSession session = MybatisUtil.getSession();
        MarketAdMapper marketAdMapper = session.getMapper(MarketAdMapper.class);
//        MarketAdExample marketAdExample = new MarketAdExample();
//        MarketAdExample.Criteria criteria = marketAdExample.createCriteria();
//        criteria.andIdEqualTo(Integer.parseInt(id));
//        int i = marketAdMapper.logicalDeleteByExample(marketAdExample);
        int i = marketAdMapper.deleteByPrimaryKey(Integer.parseInt(id));
        session.commit();
        session.close();
        return i;
    }
}
